#ifndef _TRAITS_HPP_
#define _TRAITS_HPP_

template <typename T>
class SigmaTraits
{
};

template <>
class SigmaTraits<char>
{
  public:
    typedef short int ReturnType;
};

template <>
class SigmaTraits<short>
{
  public:
    typedef int ReturnType;
};

template <>
class SigmaTraits<int>
{
  public:
    typedef long ReturnType;
};

template <>
class SigmaTraits<unsigned int>
{
  public:
    typedef unsigned long ReturnType;
};

template <>
class SigmaTraits<float>
{
  public:
    typedef double ReturnType;
};

template <typename T>
inline typename SigmaTraits<T>::ReturnType Sigma(const T *start, const T *const end)
{
    typedef typename SigmaTraits<T>::ReturnType ReturnType;
    ReturnType res = ReturnType();

    while (start != end)
    {

        res += *start++;
    }

    return res;
}

#endif